Skip to content

fix(android): crash on New Architecture in trackDeepLinks#1146

Merged
abueide merged 1 commit into
segmentio:masterfrom
RomanSytnyk:fix/new-architecture-track-deep-links
Jun 12, 2026
Merged

fix(android): crash on New Architecture in trackDeepLinks#1146
abueide merged 1 commit into
segmentio:masterfrom
RomanSytnyk:fix/new-architecture-track-deep-links

Conversation

@RomanSytnyk

@RomanSytnyk RomanSytnyk commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Crash on Expo 55

trackDeepLinks() in AnalyticsReactNativeModule.kt accesses SovranModule through the old ReactNativeHost chain:

val sovran = (reactApplicationContext.currentActivity?.application as ReactApplication)
  ?.reactNativeHost
  ?.reactInstanceManager
  ?.currentReactContext
  ?.getNativeModule(SovranModule::class.java)

This throws a RuntimeException on React Native's New Architecture (Bridgeless mode):

java.lang.RuntimeException: You should not use ReactNativeHost directly in the New Architecture

The crash happens on every app launch (onHostResume) and on deep links (onNewIntent).

Fix

Use reactApplicationContext.getNativeModule() directly

trackDeepLinks() accessed SovranModule through the old ReactNativeHost
chain (ReactApplication -> reactNativeHost -> reactInstanceManager ->
currentReactContext -> getNativeModule), which throws a RuntimeException
on React Native's New Architecture (Bridgeless mode):

  "You should not use ReactNativeHost directly in the New Architecture"

The fix uses reactApplicationContext.getNativeModule() directly, which
is the same pattern already used by setAnonymousId() in this class.

Also removes unused ReactApplication and ReactActivity imports.
@mohit-ranjan-25

Copy link
Copy Markdown

This looks good to me, can any maintainer have a look as well?

@RomanSytnyk

Copy link
Copy Markdown
Contributor Author

Fix for #1147
@MichaelGHSeg
@abueide

@s-sobati

Copy link
Copy Markdown

is there any maintainer to give this small PR a review?

@abueide abueide merged commit a58bdcc into segmentio:master Jun 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants